﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SQLite;

namespace AFT2
{
    [Serializable]
    public class CalendarDataObject
    {
        public CalendarDataObject(string id, string title, string eventLocation, string description, string dateStart, string dateEnd)
        {
            ID = id;
            Title = title;
            EventLocation = eventLocation;
            Description = description;
            DateStart = dateStart;
            DateEnd = dateEnd;            
        }

        public string ID { get; set; }
        public string Title { get; set; }
        public string EventLocation { get; set; }
        public string Description { get; set; }
        public string DateStart { get; set; }
        public string DateEnd { get; set; }        
    }
    [Serializable]
    public class CalendarDataList
    {
        public List<CalendarDataObject> data;
        public CalendarDataList()
        {
            /*
       private static final String CREATE_CALENDAR_TABLE = "create table calendar("
           + "_id integer primary key autoincrement,"			
           + "c_id text,"
           + "title text,"
           + "eventLocation text,"
           + "description text,"
           + "dtstart text,"
           + "dtend text)";
        */

            this.data = new List<CalendarDataObject>();
            SQLiteConnection myConnection = new SQLiteConnection();
            myConnection.ConnectionString = "Data Source=db\\phoneData.db";
            myConnection.Open();
            SQLiteCommand sqlcmd = new SQLiteCommand(myConnection);
            sqlcmd.CommandText = "select * from calendar";
            SQLiteDataReader reader = sqlcmd.ExecuteReader();
            while (reader.Read())
            {
                this.data.Add(new CalendarDataObject(
                        "" + reader["c_id"],
                        "" + reader["title"],
                        "" + reader["eventLocation"],
                        "" + reader["description"],
                        "" + reader["dtstart"],
                        "" + reader["dtend"]
                    ));

            }
        }
    }
}
